package com.qf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.Room;
import com.qf.entity.RoomDTO;
import com.qf.entity.SysLog;
import com.qf.entity.SysLogDTO;
import com.qf.service.SysLogService;
import com.qf.util.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: SysLogController
 * @Author: WangHao
 * @Date: 2025/5/10 17:36
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("operationLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    // 查询所有操作日志
    @PostMapping("/findAll")
    public R findAll(@RequestBody SysLogDTO sysLogDTO) {
        PageHelper.startPage(sysLogDTO.getPageNum(), sysLogDTO.getPageSize());

        List<SysLog> list =sysLogService.findAll(sysLogDTO);
        PageInfo<SysLog> pageInfo = new PageInfo<>(list);
        return R.ok(pageInfo);
    }

    // 删除操作日志
    @GetMapping("/delLogById/{id}")
    public R delById(@PathVariable("id") Integer id) {
        boolean ok = sysLogService.delById(id);
        return R.ok(ok);
    }

    // 批量删除操作日志
    @GetMapping("/delLogByIds")
    public R delByIds(Integer[] ids) {
        boolean ok = sysLogService.delByIds(ids);
        if (!ok) {
            return R.fail();
        }
        return R.ok();
    }

}
